<template>
  <div>
    <table class="userListBox">
      <tbody>
        <tr v-for="item in content" :key="item.id">
          <td class="imgTd">
            <img :src="item.avatarUrl" class="iteImg" alt="" />
          </td>
          <td class="nameTd">
            <div style="width: 100%">
              <p class="nickname txtHide">{{ item.nickname }}</p>
              <p class="signature txtHide">{{ item.signature }}</p>
            </div>
          </td>
          <td class="likeTd"></td>
          <td class="songSheetTd">歌单：{{ item.playlistCount }}</td>
          <td class="fansTd">粉丝：{{ item.followeds }}</td>
        </tr>
      </tbody>
    </table>
    <div class="pageBox">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="count"
        :page-size="pagelimit"
        :current-page.sync="contnetPage"
        :hide-on-single-page="true"
        @current-change="pageNumChange"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { Search } from "@/api";
export default {
  data() {
    return {
      content: [],
      count: 0,
      pagelimit: 30,
      contnetPage: 1,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      Search({
        keywords: this.$route.query.name,
        limit: this.pagelimit,
        offset: (this.contnetPage - 1) * this.pagelimit,
        type: 1002,
      }).then((res) => {
        // console.log(res);
        this.count = res.result.userprofileCount;
        this.content = res.result.userprofiles;
      });
    },
    pageNumChange(num) {
      this.contnetPage = num;
      this.getData();
    },
  },
};
</script>

<style lang="scss" scoped>
.pageBox {
  text-align: center;
  margin: 20px;
}
.userListBox {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 20px;
  tr {
    &:nth-child(odd) {
      background-color: #f7f7f7;
    }
    &:hover {
      border: 1px solid #e1e1e1;
      background: #f2f2f2;
    }
    td {
      padding: 6px 10px;
    }
    .imgTd {
      width: 50px;
      .iteImg {
        width: 50px;
        height: 50px;
      }
    }
    .nameTd {
      .nickname {
        font-size: 14px;
        color: #333;
      }
      .signature {
        color: #999;
        width: 100%;
        margin-top: 5px;
      }
    }
    .likeTd {
      width: 96px;
    }
    .songSheetTd {
      width: 96px;
      color: #999;
    }
    .fansTd {
      width: 96px;
      color: #999;
    }
  }
}
</style>